import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { MessageInfo } from "./info/MessageInfo";
type int = number;
//class PublicMessageConfig
    
    export  class PublicMessageConfig
    {
        constructor(arg1: ConstructorBlock)
        {
            
            this._msgsDict = new Map<any, any> /* flash.utils.Dictionary */();
            this._moduleDict = new Map<any, any> /* flash.utils.Dictionary */();
            if (PublicMessageConfig._instance != null) 
            {
                throw new Error(" PublicMessageConfig 单例 ");
            }
            PublicMessageConfig._instance = this;
            this.parseMsgXML(ConfigManager.instance.getObjectByFileName("publicMessage.xml"));
            return;
        }

        /* internal  */parseMsgXML(arg1: Object): void
        {
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc1=arg1.module as Array<any>;
            var loc2=new RegExp("\\r", "g");
            var loc7=0;
            var loc8=loc1;
            for(loc3 of loc8) 
            {
                loc4 = loc3.type.toString();
                this._moduleDict[loc4] = loc3;
                var loc9=0;
                var loc10=loc3.msg as Array<any>;
                for(loc5 of loc10) 
                {
                    (loc6 = new MessageInfo()).id = loc5.id;
                    loc6.type = loc4;
                    loc6.name = loc5.name;
                    loc6.text = (loc5.text as string).replace(loc2, "");
                    this.addItem(loc6);
                }
            }
            return;
        }

        /* internal  */addItem(arg1: MessageInfo): void
        {
            this._msgsDict[arg1.type + "-" + arg1.name] = arg1;
            return;
        }

        public getItemByName(arg1: string, arg2: string): MessageInfo
        {
            return this._msgsDict[arg1 + "-" + arg2] as MessageInfo;
        }

        public getTextByTypeAndName(arg1: string, arg2: string): string
        {
            var loc1="";
            var loc2;
            if (loc2 = this._msgsDict[arg1 + "-" + arg2] as MessageInfo) 
            {
                loc1 = loc2.text;
            }
            return loc1;
        }

        public getMailTextByName(arg1: string): string
        {
            return this.getTextByTypeAndName("Mail", arg1);
        }

        public getPetForgeTextByName(arg1: string): string
        {
            return this.getTextByTypeAndName("PetForge", arg1);
        }

        public getMountModuleTextByName(arg1: string): string
        {
            return this.getTextByTypeAndName("MountModule", arg1);
        }

        public getTextGradeByName(arg1: string): string
        {
            return this.getTextByTypeAndName("TextGrade", arg1);
        }

        public getMountGradeTile(arg1: string): string
        {
            return this.getTextByTypeAndName("MountGradeTile", arg1);
        }

        public getArenaProcess(arg1: int): string
        {
            var loc1="" + arg1;
            return this.getTextByTypeAndName("ArenaProcess", loc1);
        }

        public getArenaAdRule(arg1: string): string
        {
            return this.getTextByTypeAndName("ArenaAdRule", arg1);
        }

        public getArenaTextByName(arg1: string): string
        {
            return this.getTextByTypeAndName("Arena", arg1);
        }

        public getWrestleTextByName(arg1: string): string
        {
            return this.getTextByTypeAndName("Arena", arg1);
        }

        public getMarryDescByName(arg1: string): string
        {
            return this.getTextByTypeAndName("Marry", arg1);
        }

        public getGuildwarTextByName(arg1: string): string
        {
            return this.getTextByTypeAndName("Guildwar", arg1);
        }

        public getCoinCopyTextByName(arg1: string): string
        {
            return this.getTextByTypeAndName("CoinCopy", arg1);
        }

        public getPetMeetHelp(): string
        {
            return this.getTextByTypeAndName("PetMeet", "helpTip");
        }

        public getVIPDescription(arg1: string): string
        {
            return this.getTextByTypeAndName("vip", arg1);
        }

        public getRandomTalkMsg(): string
        {
            var loc2=NaN;
            var loc3=0;
            var loc1=this._moduleDict["OneKeyFriendMsg"].msg as Array<any>;
            if (loc1.length > 0) 
            {
                loc2 = Math.random();
                loc3 = Math.round((loc1.length - 1) * loc2);
                if (loc1[loc3]) 
                {
                    return loc1[loc3]["text"];
                }
            }
            return "";
        }

        public getFightSpiritTextByName(arg1: string): string
        {
            return this.getTextByTypeAndName("FightSpiritModule", arg1);
        }

        public getFeedMemoryTextByName(arg1: string): string
        {
            return this.getTextByTypeAndName("FeedMemoryModule", arg1);
        }

        public static get instance(): PublicMessageConfig
        {
            if (PublicMessageConfig._instance == null) 
            {
                PublicMessageConfig._instance = new PublicMessageConfig(new ConstructorBlock());
            }
            return PublicMessageConfig._instance;
        }

        /* internal */ /* var */_msgsDict: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_moduleDict: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: PublicMessageConfig;
    }
}


class ConstructorBlock
{
    public ConstructorBlock()
    {
        
        return;
    }
